<?php

	/**
 * Controller_informsytle
 */

	class Controller_informstyle extends MyApp {

		public function __construct()
		{

			parent::__construct();

			$this->model->inform    	= YOU::loadModel('inform');
			$this->model->appoint  	   	= YOU::loadModel('appoint');
			$this->model->department   	= YOU::loadModel('department');
			$this->model->staff   	    = YOU::loadModel('staff');
			$this->model->research   	= YOU::loadModel('research');
			$this->model->prepare   	= YOU::loadModel('prepare');
			$this->model->discipline   	= YOU::loadModel('discipline');
			$this->model->grade   	    = YOU::loadModel('grade');
			$this->model->audit   	    = YOU::loadModel('audit');
            $this->model->excel   	    = YOU::loadModel('excel');
            $this->model->user   	    = YOU::loadModel('user');

		}
		/** 首页 **/
		public function actionIndex()
		{

			$this->tpl->display();
		}
		/** 通知样式列表 **/
		public function actionInformStyleList()
		{
			// 分页
			YOU::loadLib('page', "", '0');

			$tmp = $this->db->fetchRow("SELECT COUNT(1) AS count FROM `tbl_inform_style`");
			$count = $tmp['count'];
			$page_total = ceil($count/PAGE_LIMIT);

			// 当前页
			$p = intval($_GET['p']);
			if ($p == 0){
				$p  = 1;
			}
			if ($p > 1){
				$start = PAGE_LIMIT * ($p-1);
			}else{
				$start = 0;
			}

			$style_lists = $this->db->fetchAll("SELECT * FROM `tbl_inform_style` ORDER BY style_id DESC LIMIT {$start}, ".PAGE_LIMIT."");

			foreach($style_lists as $key => $value){
				// 字体
				$style_lists[$key]['style_typeface'] = $this->style_name[$value['style_typeface']];
				// 加粗
				$style_lists[$key]['style_overstriking'] = $this->style_overstriking[$value['style_overstriking']];
				// 斜体
				$style_lists[$key]['style_italic'] = $this->style_italic[$value['style_italic']];
				// 颜色
				$style_lists[$key]['style_color'] = $this->style_color[$value['style_color']];

			}

			$page = new Page(array('total' => $count, 'perpage' => PAGE_LIMIT));
			$page->next_page   = '下一页>';
			$page->pre_page    = '<上一页';
			$page->style_path  = "static/page_style";

			$this->tpl->assign("page", $page->show(4, "yahoo"));
			$this->tpl->assign("style_lists", $style_lists);
			$this->tpl->display('informstyle/informstyle.style.list.tpl.php');
		}
		/** 通知样式添加 **/
		public function actionInformStyleAdd()
		{

			if ($_POST){

				$style_name	     	    = $this->post->style_name;
				$style_typeface     	= $this->post->style_typeface;
				$style_number     	    = $this->post->style_number;
				$style_overstriking	    = $this->post->style_overstriking;
				$style_italic     	    = $this->post->style_italic;
				$style_color     	    = $this->post->style_color;
				$style_mo     	        = $this->post->style_mo;
				
				if(!empty($style_mo)){
					// 默认
					$style_lists = $this->model->inform->getStyleAll();
					foreach ($style_lists as $key => $value){
						$info = array(
						"style_mo"			=> " ",
						);
						$this->db->do_update("tbl_inform_style", $info, "style_id='{$value['style_id']}'");
					}
				}
				// 写入数据库
				$info = array(

				"style_name"			=> $style_name,
				"style_typeface"      	=> $style_typeface,
				"style_number"      	=> $style_number,
				"style_overstriking"    => $style_overstriking,
				"style_italic"      	=> $style_italic,
				"style_color"			=> $style_color,
				"style_mo"			    => $style_mo,
				"status"                => 1,
				"create_time"           => date("Y-m-d H:i:s"),
				"update_time"           => "0000-00-00 00:00:00",

				);
				$this->db->do_insert("tbl_inform_style", $info);

				// 跳转
				Helper_Client::location("添加成功", "index.php?a=informstyle.InformStyleList");
			}


			$this->tpl->display('informstyle/informstyle.style.add.tpl.php');
		}
		/** 通知样式修改 **/
		public function actionInformStyleUpdate()
		{

			$style_id    = (int)$this->get->style_id;
			$style_lists = $this->model->inform->getStyleAll();
			$style_data  = $this->model->inform->getStyleinfo($style_id);

			foreach($style_lists as $key => $value){
				// 字体
				$style_lists[$key]['style_typeface'] = $this->style_name[$value['style_typeface']];
				// 加粗
				$style_lists[$key]['style_overstriking'] = $this->style_overstriking[$value['style_overstriking']];
				// 斜体
				$style_lists[$key]['style_italic'] = $this->style_italic[$value['style_italic']];
				// 颜色
				$style_lists[$key]['style_color'] = $this->style_color[$value['style_color']];

			}

			if (empty($style_data)){
				Helper_Client::alert("样式不存在");
			}

			if ($_POST){

				$style_name	     	    = $this->post->style_name;
				$style_typeface     	= $this->post->style_typeface;
				$style_number     	    = $this->post->style_number;
				$style_overstriking	    = $this->post->style_overstriking;
				$style_italic     	    = $this->post->style_italic;
				$style_color     	    = $this->post->style_color;
				$style_mo     	        = $this->post->style_mo;

				// 默认
				if(!empty($style_mo)){

					foreach ($style_lists as $key => $value){
						$info = array(
						"style_mo"			=> " ",
						);	
						$this->db->do_update("tbl_inform_style", $info, "style_id='{$value['style_id']}'");
					}
				}
				// 写入数据库
				$info = array(

				"style_name"			=> $style_name,
				"style_typeface"      	=> $style_typeface,
				"style_number"      	=> $style_number,
				"style_overstriking"    => $style_overstriking,
				"style_italic"      	=> $style_italic,
				"style_color"			=> $style_color,
				"style_mo"				=> $style_mo,
				"status"                => 1,
				"create_time"           => date("Y-m-d H:i:s"),
				"update_time"           => "0000-00-00 00:00:00",

				);

				$this->db->do_update("tbl_inform_style", $info, "style_id='{$style_id}'");

				// 跳转
				Helper_Client::location("修改成功", "index.php?a=informstyle.InformStyleList");
			}

			$this->tpl->assign("style_lists", $style_lists);
			$this->tpl->assign("style_data", $style_data);
			$this->tpl->display('informstyle/informstyle.style.update.tpl.php');
		}
		/** 通知样式删除 **/
		public function actionInformStyleDel()
		{
			$style_id = $this->get->style_id;
			$this->db->query("DELETE  FROM `tbl_inform_style` WHERE style_id='{$style_id}'");

			// 跳转
			Helper_Client::location("删除成功", "index.php?a=informstyle.InformStyleList");
		}
		/**  ------------------------   审批设置 --------------------------------- **/
		/** 审批设置列表 **/

        public function actionNoticeSetlist()
        {
        
            // 所有部门
            $department_lists = $this->model->department->getAll();

            foreach ($department_lists as $key => $value){
                $audit_type = 'department';
                // 去部门数据
                $row = $this->model->audit->getAInfoAll($audit_type,$value['department_id']);
                foreach ($row as $k => $v){
                    // 去教师姓名
                    $staff_name = $this->model->staff->getinfo($v['user_id']);
                    $department_lists[$key]['staff_name'][$k] = $staff_name['staff_name'];

                }
            }
            // 教学组
            $audit_type = 'research';
            $type_id =1;
            $research_lists = $this->model->audit->getAInfoAll($audit_type,$type_id);
            foreach ($research_lists as $key => $value){
                // 去教师姓名
                $staff_name = $this->model->staff->getinfo($value['user_id']);
                $research_lists[$key]['staff_name'] = $staff_name['staff_name'];
            }
            // 备课组
            $audit_type = 'prepare';
            $type_id =1;
            $prepare_lists = $this->model->audit->getAInfoAll($audit_type,$type_id);
            foreach ($prepare_lists as $key => $value){
                // 去教师姓名
                $staff_name = $this->model->staff->getinfo($value['user_id']);
                $prepare_lists[$key]['staff_name'] = $staff_name['staff_name'];
            }
            // 学科组
            $audit_type = 'discipline';
            $type_id =1;
            $discipline_lists = $this->model->audit->getAInfoAll($audit_type,$type_id);
            foreach ($discipline_lists as $key => $value){
                // 去教师姓名
                $staff_name = $this->model->staff->getinfo($value['user_id']);
                $discipline_lists[$key]['staff_name'] = $staff_name['staff_name'];
            }
            // 级长
            $grade_lists = $this->model->grade->getAll();
     
            foreach ($grade_lists as $key => $value){
                $audit_type = 'grade';
                // 去部门数据
                $row = $this->model->audit->getAInfoAll($audit_type,$value['grade_id']);
                foreach ($row as $k => $v){
                    // 去教师姓名
                    $staff_name = $this->model->staff->getinfo($v['user_id']);
                    $grade_lists[$key]['staff_name'][$k] = $staff_name['staff_name'];
                }

            }
            //var_dump($grade_lists);
            // 班主任
            $grades_lists = $this->model->grade->getAll();
            foreach ($grades_lists as $key => $value){
                $audit_type = 'grades';
                // 去部门数据
                $row = $this->model->audit->getAInfoAll($audit_type,$value['grade_id']);
                foreach ($row as $k => $v){
                    // 去教师姓名
                    $staff_name = $this->model->staff->getinfo($v['user_id']);
                    $grades_lists[$key]['staff_name'][$k] = $staff_name['staff_name'];
                }

            }
            //var_dump($grades_lists);
            // 修改
            // 人事任命所有人
            //$appoint_lists = $this->model->appoint->getStaffAll();
            $appoint_lists = $this->db->fetchAll("SELECT distinct staff_id FROM `tbl_appoint`WHERE `appoint_type` != 4 order by staff_id");

            //print_R($appoint_lists);
            foreach ($appoint_lists as $key => $value){
                $row = $this->model->staff->getinfo($value['staff_id']);
                $appoint_lists[$key]['staff_name'] = $row['staff_name'];
            }

            if ($_POST) {

                $staff_id	  	  = $_POST['staff_id'];
                $audit_type	  	  = $this->post->audit_type;
                $department_id	  = $this->post->department_id;
                $grade_id	  	  = $this->post->grade_id;
                $grades_id	  	  = $this->post->grades_id;
                $audit_type	  	  = $this->post->audit_type;
                $type_id	  	  = (int)$this->post->type_id;

                // 部门审批人修改
                if (!empty($department_id)) {
                    // 先删除
                    $this->db->query("DELETE  FROM `tbl_audit` WHERE type_id ={$department_id} AND audit_type ='department'");

                    foreach ($staff_id as $key => $value){

                        // 写入数据库
                        $info = array(
                            "audit_type"			=> 'department',
                            "type_id"      			=> $department_id,
                            "user_id"      			=> $value,
                            "status"                => 1,
                            "create_time"           => date("Y-m-d H:i:s"),
                            "update_time"           => "0000-00-00 00:00:00",
                        );
                        $this->db->do_insert("tbl_audit", $info);
                    }
                }
                // 教研组审批人修改
                if ($audit_type == "research") {
                    // 先删除
                    $this->db->query("DELETE  FROM `tbl_audit` WHERE  audit_type ='research'");

                    foreach ($staff_id as $key => $value){

                        // 写入数据库
                        $info = array(
                            "audit_type"			=> 'research',
                            "type_id"      			=> 1,
                            "user_id"      			=> $value,
                            "status"                => 1,
                            "create_time"           => date("Y-m-d H:i:s"),
                            "update_time"           => "0000-00-00 00:00:00",
                        );
                        $this->db->do_insert("tbl_audit", $info);
                    }
                }
                // 备课组审批人修改
                if ($audit_type == "prepare") {
                    // 先删除
                    $this->db->query("DELETE  FROM `tbl_audit` WHERE  audit_type ='prepare'");

                    foreach ($staff_id as $key => $value){

                        // 写入数据库
                        $info = array(
                            "audit_type"			=> 'prepare',
                            "type_id"      			=> 1,
                            "user_id"      			=> $value,
                            "status"                => 1,
                            "create_time"           => date("Y-m-d H:i:s"),
                            "update_time"           => "0000-00-00 00:00:00",
                        );
                        $this->db->do_insert("tbl_audit", $info);
                    }
                }
                // 学科组审批人修改
                if ($audit_type == "discipline") {
                    // 先删除
                    $this->db->query("DELETE  FROM `tbl_audit` WHERE  audit_type ='discipline'");

                    foreach ($staff_id as $key => $value){

                        // 写入数据库
                        $info = array(
                            "audit_type"			=> 'discipline',
                            "type_id"      			=> 1,
                            "user_id"      			=> $value,
                            "status"                => 1,
                            "create_time"           => date("Y-m-d H:i:s"),
                            "update_time"           => "0000-00-00 00:00:00",
                        );
                        $this->db->do_insert("tbl_audit", $info);
                    }
                }
                // 级长审批人修改
                if (!empty($grade_id)) {
                    // 先删除
                    $this->db->query("DELETE  FROM `tbl_audit` WHERE type_id ='{$grade_id}' AND audit_type ='grade'");

                    foreach ($staff_id as $key => $value){

                        // 写入数据库
                        $info = array(
                            "audit_type"			=> 'grade',
                            "type_id"      			=> $grade_id,
                            "user_id"      			=> $value,
                            "status"                => 1,
                            "create_time"           => date("Y-m-d H:i:s"),
                            "update_time"           => "0000-00-00 00:00:00",
                        );
                        $this->db->do_insert("tbl_audit", $info);
                    }
                }
                // 班主任审批人修改
                if (!empty($grades_id)) {
                    // 先删除
                    $this->db->query("DELETE  FROM `tbl_audit` WHERE type_id ='{$grades_id}' AND audit_type ='grades'");

                    foreach ($staff_id as $key => $value){

                        // 写入数据库
                        $info = array(
                            "audit_type"			=> 'grades',
                            "type_id"      			=> $grades_id,
                            "user_id"      			=> $value,
                            "status"                => 1,
                            "create_time"           => date("Y-m-d H:i:s"),
                            "update_time"           => "0000-00-00 00:00:00",
                        );
                        $this->db->do_insert("tbl_audit", $info);
                    }
                }

                Helper_Client::location("修改成功", "index.php?a=informstyle.noticesetlist");

            }

            $this->tpl->assign("department_lists", $department_lists);
            $this->tpl->assign("prepare_lists", $prepare_lists);
            $this->tpl->assign("research_lists", $research_lists);
            $this->tpl->assign("discipline_lists", $discipline_lists);

            $this->tpl->assign("grade_lists", $grade_lists);
            $this->tpl->assign("grades_lists", $grades_lists);
            $this->tpl->assign("appoint_lists", $appoint_lists);
            $this->tpl->display('informstyle/informstyle.set.list.tpl.php');
        }
//导出
        public function actionnooutdata()
        {
            $datas = array();
            // 所有部门
            $department_lists = $this->model->department->getAll();
            foreach ($department_lists as $key => $value){
                $audit_type = 'department';
                // 去部门数据
                $row = $this->model->audit->getAInfoAll($audit_type,$value['department_id']);
                foreach ($row as $k => $v){
                    // 去教师姓名
                    $staff_name = $this->model->staff->getinfo($v['user_id']);
                    $department_lists[$key]['staff_name'] .= ' '.$staff_name['staff_name'];

                }
                $arr = array($department_lists[$key]['department_name'],$department_lists[$key]['staff_name']);
                $datas[] = $arr;

            }

            // 教学组
            $audit_type = 'research';
            $type_id =1;
            $research_lists = $this->model->audit->getAInfoAll($audit_type,$type_id);
            foreach ($research_lists as $key => $value){
                // 去教师姓名
                $staff_name = $this->model->staff->getinfo($value['user_id']);
                //$research_lists[$key]['staff_name'] .= ' '.$staff_name['staff_name'];
                $names .= ' '.$staff_name['staff_name'];
                $arr = array('教学组',$names);
            }
            $datas[] = $arr;

            // 备课组
            $audit_type = 'prepare';
            $type_id =1;
            $prepare_lists = $this->model->audit->getAInfoAll($audit_type,$type_id);
           // $names = '';
            foreach ($prepare_lists as $key => $value){
                // 去教师姓名
                $staff_name = $this->model->staff->getinfo($value['user_id']);
               // $prepare_lists[$key]['staff_name'] = ' '.$staff_name['staff_name'];
                $names .= ' '.$staff_name['staff_name'];
                $arr = array('备课组',$names);
            }
            //var_dump($arr);exit;
            $datas[] = $arr;
            // 学科组
            $audit_type = 'discipline';
            $type_id =1;
            $discipline_lists = $this->model->audit->getAInfoAll($audit_type,$type_id);
            foreach ($discipline_lists as $key => $value){
                // 去教师姓名
                $staff_name = $this->model->staff->getinfo($value['user_id']);
                //$discipline_lists[$key]['staff_name'] = ' '.$staff_name['staff_name'];
                $names =  ' '.$staff_name['staff_name'];
                $arr = array('学科组',$names);
            }
            $datas[] = $arr;
            // 级长
            $grade_lists = $this->model->grade->getAll();
            foreach ($grade_lists as $key => $value){
                $audit_type = 'grade';
                // 去部门数据
                $row = $this->model->audit->getAInfoAll($audit_type,$value['grade_id']);
                $names = '';
                foreach ($row as $k => $v){
                    // 去教师姓名
                    $staff_name = $this->model->staff->getinfo($v['user_id']);
                    //$grade_lists[$key]['staff_name'] = ' '.$staff_name['staff_name'];
                    $names .= ' '.$staff_name['staff_name'];
                }
                $arr = array($grade_lists[$key]['grade_name'].'级长',$names);
                $datas[] = $arr;

            }
            // 班主任
            $grades_lists = $this->model->grade->getAll();
            foreach ($grades_lists as $key => $value){
                $audit_type = 'grades';
                // 去部门数据
                $row = $this->model->audit->getAInfoAll($audit_type,$value['grade_id']);
                $names = '';
                foreach ($row as $k => $v){
                    // 去教师姓名
                    $staff_name = $this->model->staff->getinfo($v['user_id']);
                    //$grades_lists[$key]['staff_name'] = ' '.$staff_name['staff_name'];
                    $names .= ' '.$staff_name['staff_name'];
                }
                $arr = array($grades_lists[$key]['grade_name'].'班主任',$names);
                $datas[] = $arr;

            }
            $department_lists = array_values($department_lists);
            $arr = array_merge($research_lists,$prepare_lists,$discipline_lists);

            //var_dump($datas);exit;
            $this->model->excel->outData("noticeoutda", $datas);

            //$this->tpl->display('informstyle/informstyle.set.list.tpl.php');
        }

        /** 审批设置批量添加 **/
		public function actionNoticeSetAdd()
		{
			// 取出所有部门
			$department_lists = $this->model->department->getAll();

			// 人事任命所有人
			//$appoint_lists = $this->model->appoint->getStaffAll();
            $appoint_lists = $this->db->fetchAll("SELECT distinct staff_id FROM `tbl_appoint`WHERE `appoint_type` != 4 order by staff_id");

            foreach($appoint_lists as $key => $value){
                if($value['class_id'] != 0){
                    unset($appoint_lists[$key]);

                }

            }
			foreach ($appoint_lists as $key => $value){
				$row = $this->model->staff->getinfo($value['staff_id']);
				$appoint_lists[$key]['staff_name'] = $row['staff_name'];
			}
			// 所有年级
			$grade_lists = $this->model->grade->getAll();

			if ($_POST) {

				// 部门id
				foreach ($department_lists as $key => $value){
					$de_id = $_POST["department_{$value['department_id']}"];

					if (!empty($de_id)) {
						foreach ($de_id as $k => $v){
							$audit_type  = 'department';
							// 判断是否存在，
							$rows = $this->model->audit->getAInfo($audit_type,$value['department_id'],$v);

							if (empty($rows)) {
								// 写入数据库
								$info = array(
								"audit_type"			=> 'department',
								"type_id"      			=> $value['department_id'],
								"user_id"      			=> $v,
								"status"                => 1,
								"create_time"           => date("Y-m-d H:i:s"),
								"update_time"           => "0000-00-00 00:00:00",
								);
								$this->db->do_insert("tbl_audit", $info);
							}
						}
					}
				}
				// 教研组id
				$research_id = $this->post->research;
				if (!empty($research_id)) {
					foreach($research_id as $key =>$value){
						$audit_type  = 'research';
						$type_id = 1;
						// 判断是否存在，
						$rows = $this->model->audit->getAInfo($audit_type,$type_id,$value);
						if (empty($rows)) {

							// 写入数据库
							$info = array(
							"audit_type"			=> $audit_type,
							"type_id"      			=> 1,
							"user_id"      			=> $value,
							"status"                => 1,
							"create_time"           => date("Y-m-d H:i:s"),
							"update_time"           => "0000-00-00 00:00:00",
							);
							$this->db->do_insert("tbl_audit", $info);

						}
					}
				}
				// 备课组id
				$prepare_id = $this->post->prepare;
				if (!empty($prepare_id)) {
					foreach($prepare_id as $key =>$value){
						$audit_type  = 'prepare';
						$type_id = 1;
						// 判断是否存在，
						$rows = $this->model->audit->getAInfo($audit_type,$type_id,$value);
						if (empty($rows)) {
							// 写入数据库
							$info = array(
							"audit_type"			=> $audit_type,
							"type_id"      			=> 1,
							"user_id"      			=> $value,
							"status"                => 1,
							"create_time"           => date("Y-m-d H:i:s"),
							"update_time"           => "0000-00-00 00:00:00",
							);
							$this->db->do_insert("tbl_audit", $info);

						}
					}
				}
				// 备课组id
				$discipline_id = $this->post->discipline;
				if (!empty($discipline_id)) {
					foreach($discipline_id as $key =>$value){
						$audit_type  = 'discipline';
						$type_id = 1;
						// 判断是否存在，
						$rows = $this->model->audit->getAInfo($audit_type,$type_id,$value);
						if (empty($rows)) {
							// 写入数据库
							$info = array(
							"audit_type"			=> $audit_type,
							"type_id"      			=> 1,
							"user_id"      			=> $value,
							"status"                => 1,
							"create_time"           => date("Y-m-d H:i:s"),
							"update_time"           => "0000-00-00 00:00:00",
							);
							$this->db->do_insert("tbl_audit", $info);
						}
					}
				}
				// 年级id
				foreach ($grade_lists as $key => $value){
					// 级长
					$j_id = $_POST["grade_{$value['grade_id']}"];
                    //var_dump($j_id);exit;
					if (!empty($j_id)) {
						foreach ($j_id as $k => $v){
							$audit_type  = 'grade';

							// 判断是否存在，
							$rows = $this->model->audit->getAInfo($audit_type,$value['grade_id'],$v);
							if (empty($rows)) {
								// 写入数据库
								$info = array(
								"audit_type"			=> 'grade',
								"type_id"      			=> $value['grade_id'],
								"user_id"      			=> $v,
								"status"                => 1,
								"create_time"           => date("Y-m-d H:i:s"),
								"update_time"           => "0000-00-00 00:00:00",
								);
								$this->db->do_insert("tbl_audit", $info);
							}
						}

					}
					// 班主任
					$b_id = $_POST["grades_{$value['grade_id']}"];
					if (!empty($b_id)) {
						foreach ($b_id as $k => $v){
							$audit_type  = 'grades';
							// 判断是否存在，
							$rows = $this->model->audit->getAInfo($audit_type,$value['grade_id'],$v);
							if (empty($rows)) {
								// 写入数据库
								$info = array(
								"audit_type"			=> 'grades',
								"type_id"      			=> $value['grade_id'],
								"user_id"      			=> $v,
								"status"                => 1,
								"create_time"           => date("Y-m-d H:i:s"),
								"update_time"           => "0000-00-00 00:00:00",
								);
								$this->db->do_insert("tbl_audit", $info);
							}
						}
					}
				}
				Helper_Client::location("添加成功", "index.php?a=informstyle.noticesetlist");
			}
			$this->tpl->assign("grade_lists", $grade_lists);
			$this->tpl->assign("appoint_lists", $appoint_lists);
			$this->tpl->assign("department_lists", $department_lists);
			$this->tpl->display('informstyle/informstyle.set.add.tpl.php');
		}

		/** 审批设置删除 **/
		public function actionNoticeSetDel()
		{
			$audit_type	  = $this->get->audit_type;
			$type_id	  = $this->get->type_id;
			$this->db->query("DELETE  FROM `tbl_audit` WHERE audit_type='{$audit_type}' AND type_id ='{$type_id}'");//
			// 跳转
			Helper_Client::location("删除成功", "index.php?a=informstyle.noticesetlist");

		}
		/** 审批一键删除 **/
		public function actionNoticeSetDels()
		{

			$this->db->query("DELETE  FROM `tbl_audit`");
			// 跳转
			Helper_Client::location("一键删除成功", "index.php?a=informstyle.noticesetlist");

		}
		// 导出excel
		public function actionoutData() {
			$staff_lists = $this->db->fetchAll("SELECT * FROM `tbl_staff`WHERE staff_external= '0'  ORDER BY staff_id ");
			
			$rule = $this->model->record->getInfo('teacher_list');
			$col = array();
			foreach($rule as $k => $v){
				$col[] = $v['title'];
			}
			//var_dump($col);exit;
			$info = array();

			foreach ($staff_lists as $key => $value) {
				$i = 0;
				foreach ($rule as $k => $v){

					switch ($v['name']){
						case  'staff_card':
							$info[$i] = ' '.$value[$v['name']];
							break;
						case  'staff_graduate_time':
							$info[$i] = ' '.$value[$v['name']];
							break;
						
						default:
							$info[$i] = $value[$v['name']];
					}
					$i++;

				}
				$data_lists[$key] = $info;



			}
			// var_dump($data_lists);exit;
			$this->model->excel->excel_ini['teachercount']['title'] = "教师统计表";
			$this->model->excel->excel_ini['teachercount']['col'] = $col;
			$this->model->excel->outData("teachercount", $data_lists);
		}




	}

?>